package org.icnmasjid.member.model;
// Generated Feb 5, 2008 8:40:40 AM by Hibernate Tools 3.1.0.beta4

import java.util.HashSet;
import java.util.Set;


/**
 * @struts.form include-all="true" extends="BaseForm"
 * @hibernate.class
 *         table="sub_org"
 *
 */

public class SubOrg extends org.icnmasjid.member.model.BaseObject implements java.io.Serializable {


    // Fields

    private Integer id;
    private String name;
    private String description;
    private String mailingList;
    private String classroom;
    private Set<SubOrg> children = new HashSet<SubOrg>(0);
    private SubOrg parent;


    // Constructors

    /** default constructor */
    public SubOrg() {
    }

	/** minimal constructor */
    public SubOrg(String name) {
        this.name = name;
    }

    // Property accessors
    /**
     *      *            @hibernate.id
     *             generator-class="native"
     *             type="java.lang.Integer"
     *             column="id"
     *
     */

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    /**
     *      *            @hibernate.property
     *             column="name"
     *             unique="true"
     *             length="100"
     *             not-null="true"
     *
     */

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }
    /**
     *      *            @hibernate.property
     *             column="description"
     *             length="400"
     *
     */

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    /**
     *      *            @hibernate.set
     *             lazy="true"
     *             inverse="true"
     *             cascade="all"
     *            @hibernate.collection-key
     *             column="parent_id"
     *            @hibernate.collection-one-to-many
     *             class="org.icnmasjid.member.model.SubOrg"
     *
     */

    public Set<SubOrg> getChildren() {
        return this.children;
    }

    public void setChildren(Set<SubOrg> subOrgs) {
        this.children = subOrgs;
    }

    /**
     *      *            @hibernate.many-to-one
     *             not-null="true"
     *            @hibernate.column name="parent_id"
     *
     */

    public SubOrg getParent() {
        return this.parent;
    }

    public void setParent(SubOrg subOrg) {
        this.parent = subOrg;
    }

    public String getFullName() {
    	if ( getParent() != null ) {
    		return getParent().getFullName() + " : " + getName();
    	}
    	return getName();
    }


    /**
     * toString
     * @return String
     */
     public String toString() {
	  StringBuffer buffer = new StringBuffer();

      buffer.append(getClass().getName()).append("@").append(Integer.toHexString(hashCode())).append(" [");
      buffer.append("name").append("='").append(getName()).append("' ");
      buffer.append("description").append("='").append(getDescription()).append("' ");
      buffer.append("]");

      return buffer.toString();
     }


   public boolean equals(Object other) {
         if ( (this == other ) ) return true;
		 if ( (other == null ) ) return false;
		 if ( !(other instanceof SubOrg) ) return false;
		 SubOrg castOther = ( SubOrg ) other;

		 return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
 && ( (this.getName()==castOther.getName()) || ( this.getName()!=null && castOther.getName()!=null && this.getName().equals(castOther.getName()) ) )
 && ( (this.getDescription()==castOther.getDescription()) || ( this.getDescription()!=null && castOther.getDescription()!=null && this.getDescription().equals(castOther.getDescription()) ) )
 && ( (this.getParent()==castOther.getParent()) || ( this.getParent()!=null && castOther.getParent()!=null && this.getParent().equals(castOther.getParent()) ) );
   }

   public int hashCode() {
         int result = 17;

         result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
         result = 37 * result + ( getName() == null ? 0 : this.getName().hashCode() );
         result = 37 * result + ( getDescription() == null ? 0 : this.getDescription().hashCode() );

         result = 37 * result + ( getParent() == null ? 0 : this.getParent().hashCode() );
         return result;
   }

   
   /**
    *      *            @hibernate.property
    *             column="mailing_list"
    *
    */
   
	public String getMailingList() {
		return mailingList;
	}
	
	public void setMailingList(String mailingList) {
		this.mailingList = mailingList;
	}
	
	   /**
	    *      *            @hibernate.property
	    *             column="classroom"
	    *
	    */
	   
		public String getClassroom() {
			return classroom;
		}
		
		public void setClassroom(String classroom) {
			this.classroom = classroom;
		}





}
